Micron Document
baubs git

Node / mirrors / respira / files / src / platform / browser / BrowserFileService.ts

Displaying Raw • Download

src/platform/browser/BrowserFileService.ts refactor/extract-sub-components (095c879e) Text, 907 B

import type { IFileService } from "../interfaces/IFileService";

/**
* Browser implementation of file service using HTML input elements
*/
export class BrowserFileService implements IFileService {
async openFileDialog(options: { accept: string }): Promise<File | null> {
return new Promise((resolve) => {
const input = document.createElement("input");
input.type = "file";
input.accept = options.accept;

input.onchange = (e) => {
const file = (e.target as HTMLInputElement).files?.[0];
resolve(file || null);
};

input.oncancel = () => {
resolve(null);
};

input.click();
});
}

async saveFileDialog(): Promise<void> {
// No-op in browser - could implement download if needed in the future
console.warn("saveFileDialog not implemented in browser");
}

hasNativeDialogs(): boolean {
return false;
}
}

Served by rngit 1.3.3 - Generated in 0.02s